#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QDialog>
#include <QThread>
#include <Ice/Ice.h>
#include <Glacier2/Glacier2.h>
#include <IceStorm/IceStorm.h>
#include "RobotDef.h"
#include <QMessageBox>
#include "RobotDef1.h"
#include "dlglogin.h"
#include "dlgrobotlist.h"
#include "tmsendmsg.h"
#include "tmrtmpctrl.h"

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

    void init();

    void getRobotList();

    bool sendMsg(QString strMsg);

    void setHeadData(int nFlag, int nAngle);
    void controlHead(int nFlag, int nAngle, int nSpeed);
    void setFace(const QModelIndex &faceIndex);
signals:
    void sig_getReply();

    void sig_sendMsg(QString userName,QString mac,QString strMsg,NetWorkRobot::UserMangerPrx *m_prxUser);

    void sig_getVideoLive(QString m_ip,QLabel *pWidget);
    void sig_stopVideoLive();
    void sig_startAudioLive(QString m_ip);
    void sig_stopAudioLive();


private slots:  
    void slot_login();
    void slot_loginInfo(QString m_ip,QString m_name,QString m_pwd);

    void slot_updateRobotList();
    void slot_conn(QString mac);

    void slot_disconn();

    void slot_showRobotList();

    void on_pushButton_send_clicked();

    void on_btn_py_start_clicked();

    void on_btn_py_stop_clicked();

    void on_btn_head_up_clicked();

    void on_btn_head_left_clicked();

    void on_btn_head_right_clicked();

    void on_btn_head_down_clicked();

    void on_pushButton_head_reset_clicked();

    void on_list_face_doubleClicked(const QModelIndex &index);

    void on_Btn_talk_clicked();

    void on_Btn_pub_clicked();

    void on_Btn_sub_clicked();

    void on_Btn_stop_clicked();

    void on_Btn_get_clicked();

private:
    Ui::MainWindow *ui;

    Glacier2::SessionFactoryHelperPtr _factory;
    Glacier2::SessionHelperPtr _session;
    NetWorkRobot::UserMangerPrx m_prxUser;

    QString m_strName;
    QString m_strMac;

    Glacier2::SessionHelperPtr m_session;

    Robot::LivePrx m_prxLive;
    DlgLogin *pr_DlgLogin;
    DlgRobotList *pr_DlgRobotList;
    TMSendMsg *pr_SendMsg;
    TMRTMPCtrl *pr_RTMPCtrl;

    IceStorm::TopicManagerPrx m_topicManager;
    Ice::ObjectPrx m_prxSub;
    Robot::PubPrx m_prxPub;

    QString m_connIP;
    int m_nHeadUD;
    int m_nHeadLR;
};

#endif // MAINWINDOW_H
